gl renderer: Add own graphene_rect_intersects
authorTimm Bäder <mail@baedert.org>
Fri, 24 Jul 2020 15:01:32 +0000 (17:01 +0200)
committerTimm Bäder <mail@baedert.org>
Tue, 28 Jul 2020 03:34:11 +0000 (05:34 +0200)
gsk/gl/gskglrenderer.c

index 1b188fddfe0075b3895d5a439a6a776797ebcc9d..62ad9f8b9fe07f9a555d637f1820e97dc5bdf146 100644 (file)
@@ -191,7 +191,7 @@ dump_node (GskRenderNode *node,
   cairo_surface_destroy (surface);
 }
 
-static inline gboolean G_GNUC_PURE
+static inline bool G_GNUC_PURE __attribute__((always_inline))
 node_is_invisible (const GskRenderNode *node)
 {
   return node->bounds.size.width == 0.0f ||
@@ -200,6 +200,22 @@ node_is_invisible (const GskRenderNode *node)
          isnan (node->bounds.size.height);
 }
 
+static inline bool G_GNUC_PURE __attribute__((always_inline))
+graphene_rect_intersects (const graphene_rect_t *r1,
+                          const graphene_rect_t *r2)
+{
+  /* Assume both rects are already normalized, as they usually are */
+  if (r1->origin.x > (r2->origin.x + r2->size.width) ||
+      (r1->origin.x + r1->size.width) < r2->origin.x)
+    return false;
+
+  if (r1->origin.y > (r2->origin.y + r2->size.height) ||
+      (r1->origin.y + r1->size.height) < r2->origin.y)
+    return false;
+
+  return true;
+}
+
 static inline void
 sort_border_sides (const GdkRGBA *colors,
                    int           *indices)
@@ -1152,20 +1168,20 @@ intersect_rounded_rectilinear (const graphene_rect_t *non_rounded,
 
   /* Intersects with top left corner? */
   n_corners += corners[0] = rounded_rect_has_corner (rounded, 0) &&
-                            graphene_rect_intersection (non_rounded,
-                                                        &rounded_rect_corner (rounded, 0), NULL);
+                            graphene_rect_intersects (non_rounded,
+                                                      &rounded_rect_corner (rounded, 0));
   /* top right? */
   n_corners += corners[1] = rounded_rect_has_corner (rounded, 1) &&
-                            graphene_rect_intersection (non_rounded,
-                                                        &rounded_rect_corner (rounded, 1), NULL);
+                            graphene_rect_intersects (non_rounded,
+                                                      &rounded_rect_corner (rounded, 1));
   /* bottom right? */
   n_corners += corners[2] = rounded_rect_has_corner (rounded, 2) &&
-                            graphene_rect_intersection (non_rounded,
-                                                        &rounded_rect_corner (rounded, 2), NULL);
+                            graphene_rect_intersects (non_rounded,
+                                                      &rounded_rect_corner (rounded, 2));
   /* bottom left */
   n_corners += corners[3] = rounded_rect_has_corner (rounded, 3) &&
-                            graphene_rect_intersection (non_rounded,
-                                                        &rounded_rect_corner (rounded, 3), NULL);
+                            graphene_rect_intersects (non_rounded,
+                                                      &rounded_rect_corner (rounded, 3));
 
   if (corners[0] && !graphene_rect_contains_rect (non_rounded, &rounded_rect_corner (rounded, 0)))
     return false;
@@ -3171,8 +3187,8 @@ gsk_gl_renderer_add_render_ops (GskGLRenderer   *self,
                                     &node->bounds,
                                     &transformed_node_bounds);
 
-    if (!graphene_rect_intersection (&builder->current_clip->bounds,
-                                     &transformed_node_bounds, NULL))
+    if (!graphene_rect_intersects (&builder->current_clip->bounds,
+                                   &transformed_node_bounds))
       return;
   }